package com.esri.core.geometry;

import com.github.mikephil.charting.utils.Utils;
import java.util.Comparator;

/* loaded from: classes.dex */
final class Point2D {
    public double x;
    public double y;

    public Point2D() {
    }

    public Point2D(double d, double d2) {
        this.x = d;
        this.y = d2;
    }

    public static Point2D construct(double d, double d2) {
        return new Point2D(d, d2);
    }

    public void setCoords(double d, double d2) {
        this.x = d;
        this.y = d2;
    }

    public void setCoords(Point2D point2D) {
        this.x = point2D.x;
        this.y = point2D.y;
    }

    public boolean isEqual(Point2D point2D) {
        return this.x == point2D.x && this.y == point2D.y;
    }

    public void sub(Point2D point2D) {
        this.x -= point2D.x;
        this.y -= point2D.y;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(Point2D point2D, Point2D point2D2) {
        this.x = point2D.x - point2D2.x;
        this.y = point2D.y - point2D2.y;
    }

    public void add(Point2D point2D) {
        this.x += point2D.x;
        this.y += point2D.y;
    }

    public void add(Point2D point2D, Point2D point2D2) {
        this.x = point2D.x + point2D2.x;
        this.y = point2D.y + point2D2.y;
    }

    public void negate() {
        this.x = -this.x;
        this.y = -this.y;
    }

    public void negate(Point2D point2D) {
        this.x = -point2D.x;
        this.y = -point2D.y;
    }

    public void interpolate(Point2D point2D, double d) {
        double d2 = 1.0d - d;
        this.x = (this.x * d2) + (point2D.x * d);
        this.y = (this.y * d2) + (point2D.y * d);
    }

    public void interpolate(Point2D point2D, Point2D point2D2, double d) {
        double d2 = 1.0d - d;
        this.x = (point2D.x * d2) + (point2D2.x * d);
        this.y = (point2D.y * d2) + (point2D2.y * d);
    }

    public void scaleAdd(double d, Point2D point2D) {
        this.x = (this.x * d) + point2D.x;
        this.y = (this.y * d) + point2D.y;
    }

    public void scaleAdd(double d, Point2D point2D, Point2D point2D2) {
        this.x = (point2D.x * d) + point2D2.x;
        this.y = (point2D.y * d) + point2D2.y;
    }

    public void scale(double d, Point2D point2D) {
        this.x = point2D.x * d;
        this.y = d * point2D.y;
    }

    public void scale(double d) {
        this.x *= d;
        this.y *= d;
    }

    int a(Point2D point2D) {
        double d = this.y;
        double d2 = point2D.y;
        if (d >= d2) {
            if (d > d2) {
                return 1;
            }
            double d3 = this.x;
            double d4 = point2D.x;
            if (d3 >= d4) {
                return d3 > d4 ? 1 : 0;
            }
        }
        return -1;
    }

    void b(Point2D point2D) {
        double length = point2D.length();
        if (length == Utils.DOUBLE_EPSILON) {
            this.x = 1.0d;
            this.y = Utils.DOUBLE_EPSILON;
            return;
        }
        this.x = point2D.x / length;
        this.y = point2D.y / length;
    }

    public void normalize() {
        double length = length();
        if (length == Utils.DOUBLE_EPSILON) {
            this.x = 1.0d;
            this.y = Utils.DOUBLE_EPSILON;
        }
        this.x /= length;
        this.y /= length;
    }

    public double length() {
        double d = this.x;
        double d2 = this.y;
        return Math.sqrt((d * d) + (d2 * d2));
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public double a() {
        double d = this.x;
        double d2 = this.y;
        return (d * d) + (d2 * d2);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static double b(Point2D point2D, Point2D point2D2) {
        double d = point2D.x - point2D2.x;
        double d2 = point2D.y - point2D2.y;
        return (d * d) + (d2 * d2);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static double c(Point2D point2D, Point2D point2D2) {
        return Math.sqrt(sqrDistance(point2D, point2D2));
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public double c(Point2D point2D) {
        return (this.x * point2D.x) + (this.y * point2D.y);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public double d(Point2D point2D) {
        return Math.abs(this.x * point2D.x) + Math.abs(this.y * point2D.y);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public double e(Point2D point2D) {
        return (this.x * point2D.y) - (this.y * point2D.x);
    }

    void a(double d, double d2) {
        double d3 = this.x;
        double d4 = this.y;
        this.x = (d3 * d) - (d4 * d2);
        this.y = (d3 * d2) + (d4 * d);
    }

    void b(double d, double d2) {
        double d3 = this.x;
        double d4 = this.y;
        this.x = (d3 * d) + (d4 * d2);
        this.y = ((-d3) * d2) + (d4 * d);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void b() {
        double d = this.x;
        this.x = -this.y;
        this.y = d;
    }

    void f(Point2D point2D) {
        this.x = -point2D.y;
        this.y = point2D.x;
    }

    void c() {
        double d = this.x;
        this.x = this.y;
        this.y = -d;
    }

    void g(Point2D point2D) {
        this.x = point2D.y;
        this.y = -point2D.x;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void d() {
        this.x = NumberUtils.NaN();
        this.y = NumberUtils.NaN();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean e() {
        return NumberUtils.isNaN(this.x);
    }

    int f() {
        double d = this.x;
        if (d > Utils.DOUBLE_EPSILON) {
            return this.y >= Utils.DOUBLE_EPSILON ? 1 : 4;
        } else if (this.y > Utils.DOUBLE_EPSILON) {
            return 2;
        } else {
            return d == Utils.DOUBLE_EPSILON ? 4 : 3;
        }
    }

    static int d(Point2D point2D, Point2D point2D2) {
        int f = point2D.f();
        int f2 = point2D2.f();
        if (f2 != f) {
            return f < f2 ? -1 : 1;
        }
        double e = point2D.e(point2D2);
        if (e < Utils.DOUBLE_EPSILON) {
            return 1;
        }
        return e > Utils.DOUBLE_EPSILON ? -1 : 0;
    }

    /* loaded from: classes.dex */
    static class CompareVectors implements Comparator {
        CompareVectors() {
        }

        @Override // java.util.Comparator
        public int compare(Object obj, Object obj2) {
            return Point2D.d((Point2D) obj, (Point2D) obj2);
        }
    }

    public static double sqrDistance(Point2D point2D, Point2D point2D2) {
        double d = point2D.x - point2D2.x;
        double d2 = point2D.y - point2D2.y;
        return (d * d) + (d2 * d2);
    }

    public String toString() {
        return "(" + this.x + " , " + this.y + ")";
    }

    double a(int i) {
        if (i < 0 || e()) {
            return NumberUtils.NaN();
        }
        if (i == 0) {
            return Math.abs(Math.abs(this.x) >= Math.abs(this.y) ? this.x : this.y);
        } else if (i != 1) {
            if (i == 2) {
                double d = this.x;
                double d2 = this.y;
                return Math.sqrt((d * d) + (d2 * d2));
            }
            double d3 = i;
            Double.isNaN(d3);
            return Math.pow(Math.pow(this.x, d3) + Math.pow(this.y, d3), 1.0d / d3);
        } else {
            return Math.abs(this.x) + Math.abs(this.y);
        }
    }
}
